package com.ruoyi.Fees.controller;

import com.ruoyi.Fees.domain.Fees;
import com.ruoyi.Fees.service.IFeesService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("Fees/fees")
public class FeesTbFeesController extends BaseController {
    @Autowired
    private IFeesService FeesService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('Fees:fees:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fees fees)
    {
        startPage();
        List<Fees> list = FeesService.selectFeesList(fees);
        return getDataTable(list);
    }


    @PreAuthorize("@ss.hasPermi('Fees:fees:edit')")
    @Log(title = "修改状态", businessType = BusinessType.UPDATE)
    @PutMapping("/changeState")
    public AjaxResult changeStatus(@RequestBody Fees fees)
    {
        return toAjax(FeesService.updateFeesState(fees));
    }

    /**
     * 根据部门编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('Fees:fees:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable Long fid)
    {
        return success(FeesService.selectFeesByFid(fid));
    }

    @PreAuthorize("@ss.hasPermi('Fees:fees:remove')")
    @Log(title = "删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(FeesService.deleteFeesByFids(fids));
    }

    @PreAuthorize("@ss.hasPermi('Fees:fees:edit')")
    @Log(title = "编辑", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fees Fees)
    {
        return toAjax(FeesService.updateFees(Fees));
    }

    @PreAuthorize("@ss.hasPermi('system:fees:add')")
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fees Fees)
    {
        return toAjax(FeesService.insertFees(Fees));
    }


}
